package com.sso.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "sso_DicHuman")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@NamedQueries( {
		@NamedQuery(name = "dh.getHumanByHumanname", query = "from DicHuman  where humanName like ? order by humanName"),
		@NamedQuery(name = "dh.getHumanBySystem", query = "from DicHuman as human  where human.system.id=?"),
		@NamedQuery(name = "dh.getHumanBySystemName", query = "from DicHuman as human  where human.system.systemName like ?") })
public class DicHuman {

	/**
	 * ID
	 */
	@Id
	private String id;

	/**
	 * 用户名称
	 */
	private String humanName;

	/**
	 * 用户密码
	 */
	private String humanPassword;

	/**
	 * 系统标识
	 */
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "systemId")
	private DicSystem system;

	@OneToMany(mappedBy = "human", cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private Set<DicUserHuman> duhs;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getHumanName() {
		return humanName;
	}

	public void setHumanName(String humanName) {
		this.humanName = humanName;
	}

	public String getHumanPassword() {
		return humanPassword;
	}

	public void setHumanPassword(String humanPassword) {
		this.humanPassword = humanPassword;
	}

	public DicSystem getSystem() {
		return system;
	}

	public void setSystem(DicSystem system) {
		this.system = system;
	}

	public Set<DicUserHuman> getDuhs() {
		return duhs;
	}

	public void setDuhs(Set<DicUserHuman> duhs) {
		this.duhs = duhs;
	}
}
